package com.yllt4cloud.common.core.exception;

import com.yllt4cloud.common.core.constant.ErrorCode;
import com.yllt4cloud.common.core.constant.enums.ValueEnum;

/**
 * @description: 自定义异常类，包括异常码，异常描述信息和错误的异常堆栈信息
 * @author: yaoxj
 * @create: 2019-09-11 16:32
 **/
public class MessageException extends RuntimeException  {


    private String errorMsg = "运行正确";
    private int errorCode = ErrorCode.SUCCESS;
    private Exception ex;

    public MessageException(String errorMsg, int errorCode) {
        this.errorMsg = errorMsg;
        this.errorCode = errorCode;
    }

    public MessageException(ValueEnum valueEnum) {
        this.errorMsg = valueEnum.getName();
        this.errorCode = (int) valueEnum.value();
    }


	public MessageException(String msg) {
		super(msg);
		setErrorCode(ErrorCode.SUCCESS);
		setErrorMsg(msg);
	}

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    public int getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }



    public Exception getEx() {
        return ex;
    }

    public void setEx(Exception ex) {
        this.ex = ex;
    }





}
